package com.jic.member.impl;

import java.lang.Long;
import java.util.List;
import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;
import com.jic.member.entity.SmsLog;
import com.jic.member.mapper.SmsLogMapper;
import com.jic.member.service.SmsLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 短信验证码记录表
 * @author : 
 * @email : 
 * @since : 2020-03-02 11:28:15
 * @version : v1.0.0
 */
@Service
public class SmsLogServiceImpl implements SmsLogService {

    @Autowired
    private SmsLogMapper smsLogMapper;

    @Override
    public long insert(SmsLog smsLog) {
        long flag = smsLogMapper.insert(smsLog);
        return flag;
    }

    @Override
    public long delete(Long id) {
        return smsLogMapper.delete(id);
    }

    @Override
    public long update(SmsLog smsLog) {
        return smsLogMapper.update(smsLog);
    }

    @Override
    public SmsLog queryByPrimaryKey(Long id){
        return smsLogMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<SmsLog> query(SmsLog smsLog){
        return smsLogMapper.query(smsLog);
    }

    @Override
    public PageResult<SmsLog> queryPage(SmsLog smsLog, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<SmsLog> list = smsLogMapper.queryPage(startIndex, pageQuery.getLimit(), smsLog);
        long count = smsLogMapper.queryPageCount(smsLog);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }
}